package com.example.ssm.dao;

import com.example.ssm.entity.Bill;
import com.example.ssm.entity.Merchant;
import com.example.ssm.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


import java.util.List;

public interface billDao {
    @Insert("insert into onlinesys.bill(shop_name, shopid, user_name, price, pay,shopName,type) VALUES (#{shop_name},#{shopid},#{user_name},#{price},0,#{shopName},#{type})")
    boolean insertBill(Bill bill);

    @Select("select *from onlinesys.bill where user_name=#{uname} and pay=0")
    List<Bill> selectNoPayByUserName(User user);
    @Select("select *from onlinesys.bill where user_name=#{uname} and pay=1")
    List<Bill> selectPayByUserName(User user);

    @Delete("delete from onlinesys.bill where id=#{id}")
    boolean delNoPayById(Bill bill);

    @Update("update onlinesys.bill set pay=1 where user_name=#{uname}")
    boolean updateBill(User user);

    @Select("select *from onlinesys.bill where shop_name=#{shop_name} and pay=0")
    List<Bill> selectNoPayByshop_name(Merchant merchant);
    @Select("select *from onlinesys.bill where shop_name=#{shop_name} and pay=1")
    List<Bill> selectPayByshop_name(Merchant Merchant);
    @Select("select shopid and price from onlinesys.bill where user_name=${uname} and pay=1")
    List<String> selectBillShopId(User user);


}
